﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using SubSonic;
using LinFen;

public partial class webUserControl_Statistics : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void ddlCityID_SelectedIndexChanged(object sender, EventArgs e)
    {
        ddlDistrictID.DataBind();
    }
    protected void btnSub_Click(object sender, EventArgs e)
    {
        Query q=new Query("supplierinfo");
        q.AddWhere("cityid", ddlCityID.SelectedValue);
        q.AddWhere("DistrictID", ddlDistrictID.SelectedValue);
        q.AddWhere("dangciid", ddlDangCiID.SelectedValue);
        q.AddWhere("CatalogID", ddlCatalogID.SelectedValue);
        //q.SelectList =
        //    "sum(numMale),sum(numMale_O),sum(numFemale),sum(numFemale_O),sum(numHongGan),sum(numHongGan_O),sum(numBaoJian),sum(numBaoJian_O),sum(numQita),sum(numQita_O)";
        //q.GetSum("nummale").ToString();
        if(q.GetRecordCount()>0)
        {
            int numMale = int.Parse(q.GetSum("nummale").ToString());
            int _numMale = int.Parse(q.GetSum("numMale_O").ToString());
            int numFemale = int.Parse(q.GetSum("numFemale").ToString());
            int _numFemale = int.Parse(q.GetSum("numFemale_O").ToString());
            int numHongGan = int.Parse(q.GetSum("numHongGan").ToString());
            int _numHongGan = int.Parse(q.GetSum("numHongGan_O").ToString());
            int numBaojian = int.Parse(q.GetSum("numBaoJian").ToString());
            int _numBaojian = int.Parse(q.GetSum("numBaoJian_O").ToString());
            int numQiTa = int.Parse(q.GetSum("numQita").ToString());
            int _numQiTa = int.Parse(q.GetSum("numQita_O").ToString());

            lblMale2.Text = numMale.ToString();
            lblFemale2.Text = numFemale.ToString();
            lblHongGan2.Text = numHongGan.ToString();
            lblBaoJian2.Text = numBaojian.ToString();
            lblQiTa2.Text = numQiTa.ToString();
            lblTotal2.Text = (numMale + numFemale + numHongGan + numBaojian + numQiTa).ToString();

            lblMale3.Text = _numMale.ToString();
            lblFemale3.Text = _numFemale.ToString();
            lblHongGan3.Text = _numHongGan.ToString();
            lblBaoJian3.Text = _numBaojian.ToString();
            lblQiTa3.Text = _numQiTa.ToString();
            lblTotal3.Text = (_numMale + _numFemale + _numHongGan + _numBaojian + _numQiTa).ToString();

            lblMale1.Text = (_numMale - numMale).ToString();
            lblFemale1.Text = (_numFemale - numFemale).ToString();
            lblHongGan1.Text = (_numHongGan - numHongGan).ToString();
            lblBaoJian1.Text = (_numBaojian - numBaojian).ToString();
            lblQiTa1.Text = (_numQiTa - numQiTa).ToString();
            lblTotal1.Text = ((_numMale + _numFemale + _numHongGan + _numBaojian + _numQiTa) - (numMale + numFemale + numHongGan + numBaojian + numQiTa)).ToString();

            lblMale4.Text = ( float.Parse(numMale.ToString()) /  float.Parse(_numMale.ToString())).ToString("P");
            lblFemale4.Text = (float.Parse(numFemale.ToString()) / float.Parse(_numFemale.ToString())).ToString("P");
            lblHongGan4.Text = (float.Parse(numHongGan.ToString()) / float.Parse(_numHongGan.ToString())).ToString("P");
            lblBaoJian4.Text = (float.Parse(numBaojian.ToString()) / float.Parse(_numBaojian.ToString())).ToString("P");
            lblQiTa4.Text = (float.Parse(numQiTa.ToString()) / float.Parse(_numQiTa.ToString())).ToString("P");
            lblTotal4.Text =
                (float.Parse((numMale + numFemale + numHongGan + numBaojian + numQiTa).ToString())/
                 float.Parse((_numMale + _numFemale + _numHongGan + _numBaojian + _numQiTa).ToString())).ToString("P");
        }
    }
}
